home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / comm / brc_asp1.zip / EXECAUTO.ASP next >
Text File  |  1992-01-27  |  14KB  |  353 lines

  1. ; Script File: EXECAUTO.ASP
  2.  
  3. comment  ; begin a comment block
  4.   Note: This script is written for ProComm Plus version 2.  !!!
  5.   NOTE: I am using the '^' character to jump to the top menu in a
  6.         number of places.  ProComm Plus uses '^' as a control character
  7.         (for example, '^M' is a carriage return.  In order to send a
  8.         single '^' I have to code TRANSMIT "^^^".  It looks screwy
  9.         but it works!
  10.  
  11.   This script can be used in a cold-start mode (let it do the dialing
  12.   in an unattended session) -or- it can be called up after a connection
  13.   is made (you must be at the main menu).  For instance, I sometimes start
  14.   a call from my 'get connected and log-on' script to read/send/answer
  15.   messages, do file scans or whatever and then invoke this script so
  16.   that it can do my accesses, downloads and Turbo message reads.
  17.  
  18.   You should be logged into your download directory.
  19.   This script is written for a modem that uses the Hayes/AT command set.
  20.   If your modem is different, change the dialing command and response code.
  21.  
  22.   *****  Instant commands must be "on" on EXEC-PC.         *****
  23.   *****  Your download protocol on EXEC-PC must be Zmodem.  *****
  24.  
  25.   The files 'EXECACCS.?' and 'EXECFILE.?' used in the (A)ccess and
  26.   (D)ownload procedures contain filenames and descriptions.
  27.   I build them with the LIST program, selecting and writing/appending
  28.   lines to them while viewing file lists in logfiles.  After the downloads
  29.   are finished for each file area, I append the EXECFILE.? file to 
  30.   another file named 'download.log'.
  31.   I run a program at the end of the script that inserts these descriptions
  32.   into the downloaded ZIP files and changes the DATE/TIME of the ZIP
  33.   files to the date/time of the newest file each contains.
  34.  
  35.   EXECACCS.? and EXECFILE.? (and the file 'download.log') look like this:
  36. JOKIN-31.ZIP  28383 110591 JOKIN AROUND JOKE SERIES  #31
  37. EXECSRCH.ZIP  27984 123188+SEARCH EXEC-PC LISTINGS FOR STRINGS - OFFLINE SAVE
  38. XFERNREV.ZIP   7660 020689 UTILITY TO REVERSE ORDER OF EXEC-PC XFER.ARC FILES
  39.  
  40.  The file extension is the letter of the file area.  This script uses:
  41.  (A) Mahoney/Dos          - EXECACCS.A and EXECFILE.A
  42.  (B) File list files      - EXECACCS.B and EXECFILE.B
  43.  (C) Free to all users    - EXECACCS.C and EXECFILE.C
  44.  (H) Adult files          - EXECACCS.H and EXECFILE.H
  45.  (I) Picture files        - EXECACCS.I and EXECFILE.I
  46. endcomment   ; end the comment block
  47.  
  48.  
  49. proc main      ; Let's get started.
  50. restart:           ; we may come back here if we lose our connection
  51.  
  52. ; The two 'when' statements are active for the life of the call.
  53. when 0 "Press any key to continue ->" transmit "^M"
  54. when 1 "More? ([Y]/Stop/Continuous" transmit "~~~~~~C"
  55.  
  56. if connected   ; this statement allows use of this script during a call
  57.    goto do_files  ; skip the log open/dialing/mail procedures
  58.    endif
  59.  
  60. ;  Build a name for the log file: EXECmmdd.LOG
  61. assign s0 "exec"
  62. date s2            ; capture the date as mm/dd/yy
  63. substr s1 s2 0 2   ; extract the month
  64. strcat s0 s1       ; append: execMM
  65. substr s1 s2 3 2   ; extract the day
  66. strcat s0 s1       ; append: execMMDD
  67. strcat s0 ".log"   ; append: execMMDD.log
  68. log open s0        ; open (create or append) the logfile
  69. ;
  70. dialexec:
  71. if not fromddir    ; if not called via the dialing directory
  72.    clear
  73.    time s4 0
  74.    date s5
  75.    box 0 14 4 65 79
  76.    fatsay 2 19 78 "Dialing EXEC-PC at %s on %s" s4 s5
  77.    locate 8 0
  78.    transmit "ATDT~789-4210^M"  ; dial EXEC-PC with commands to the modem
  79.    waitfor "connect" 60        ; wait 60 seconds for a connection
  80.    if not waitfor              ; if modem did not return "connect"
  81.       hangup
  82. ;;;;  pause 9900               ; pause for 2 hours & 45 minutes
  83.       pause 3600               ; pause for 1 hour
  84.       goto dialexec            ; try again
  85.       endif
  86.    endif
  87.  
  88. if not connected    ; if connection was lost
  89.    log close        ; close the log file
  90.    hangup           ; hang up the phone
  91.    goto restart     ; try again
  92.    endif
  93.  
  94. if not fromddir      ; if not originated from the dialing directory
  95.    waitfor  "What is your FIRST name ->" 90
  96.    transmit "firstname^M"
  97.    waitfor  "What is your  LAST name ->" 90
  98.    transmit "lastname^M"
  99.    waitfor  "Password ->" 90
  100.    transmit "password;Q^M"  ; go directly to the top menu
  101.    waitfor "?=HELP) ->" 90        ; Wait for top command
  102.    if not connected               ; If connection was lost
  103.       log close                   ; close the logfile
  104.       hangup                      ; hang up the phone
  105.       goto restart                ; Start over again
  106.       endif                       ; (if not connected)
  107.    endif                          ; (if not fromddir)
  108.  
  109. transmit ";"                      ; should be at Top Menu
  110. waitfor "Chain->"
  111. transmit "~~B;*^M"                ; read bulletins
  112. waitquiet 10 forever              ; end of bulletins
  113. transmit "q"                      ; quit bulletin menu
  114. waitfor "?=HELP) ->"              ; Wait for top command
  115.  
  116. ; Read my mail (if any) and leave it marked for later retrieval
  117. transmit ";"
  118. waitfor "Chain->"
  119. transmit "R;N^M"
  120. waitquiet 15 forever   ; wait forever for 15 seconds of quiet
  121.  
  122. ;  start of file processing **********************************************
  123. ;  call each procedure using the file area designation
  124. do_files:
  125. call newfiles with "a"         ; get new files from Mahoney list (A)
  126. call accesser with "a"         ; see if any files to access
  127. call download with "a"         ; see if any files to download
  128.  
  129. call newfiles with "b"         ; get new 'file list' files (B)
  130. call accesser with "b"         ; see if any files to access
  131. call download with "b"         ; see if any files to download
  132.  
  133. call newfiles with "c"         ; get new files from free utility/variety list
  134. call accesser with "c"         ; see if any files to access
  135. call download with "c"         ; see if any files to download
  136.  
  137. call newfiles with "h"         ; get new files from adult list (H)
  138. call accesser with "h"         ; see if any files to access
  139. call download with "h"         ; see if any files to download
  140.  
  141. call newfiles with "i"         ; get new files from GIF list (I)
  142. call accesser with "i"         ; see if any files to access
  143. call download with "i"         ; see if any files to download
  144.  
  145. transmit "^^^"                 ; let's make doubly sure
  146. waitfor "?=HELP) ->" 15        ; should be back in Top Menu
  147.  
  148. if not connected               ; If connection was lost
  149.    log close                   ; close the logfile
  150.    hangup                      ; hang up the phone
  151.    goto restart                ; Start over again
  152.    endif
  153. ;  end of file processing *************************************************
  154.  
  155. ; now we are going to read all of the new messages
  156. ; in all of the conferences we have joined
  157. transmit ";"
  158. waitfor "Chain->" 90
  159. transmit "~~m;*;n;f;n;n;t^M"   ; read all joined message areas in Turbo mode
  160. waitquiet 30 forever           ; wait forever for 30 seconds of quiet
  161.  
  162. transmit "^^^"                 ; go to TOP MENU
  163. waitfor "?=HELP) ->" 90
  164.  
  165. if not connected
  166.    goto lost_it
  167.    endif
  168.  
  169. transmit ";"
  170. waitfor "Chain->" 30
  171. transmit "~~g;n^M"             ; <G>oodbye, <N>o message
  172. waitfor "click"                ; EXEC-PC's disconnection signal
  173.  
  174. lost_it:
  175. log close                      ; close the logfile
  176.  
  177. if connected                   ; if we're still connected
  178.    hangup                      ; hang up the phone
  179.    endif
  180.  
  181. comment
  182. The following line runs the 'add comment & fix date' program.  It uses 
  183. the file 'c:\pcplus\asp\download.log' to insert the EXEC-PC file list 
  184. description into the comment area of downloaded ZIP files and changes
  185. their date to reflect the latest date of any file within the ZIP.
  186. The 'zipcomdt' program should be accessible through your 'path'.
  187. See the download procedure regarding the download log file.
  188. endcomment
  189.  
  190. dos "zipcomdt c:\pcplus\asp\download.log" noclear
  191. quit     ; exit ProComm Plus, go back to DOS
  192. endproc  ; end of the Main procedure
  193.  
  194.  
  195. ;**********************************************
  196. proc newfiles                  ; list new files since last call
  197. strparm filearea               ; file area to list (A/B/C/D/etc)
  198. string request = "~~f;?;n^M"   ; Files/area/New
  199.  
  200. strupdt request filearea 4 1   ; plug file area in place of ?
  201. transmit ";"
  202. waitfor "Chain->" 90
  203. transmit request               ; get new files the file list
  204. waitfor ">>END OF LIST" 300    ; wait for end of list
  205. pause 2
  206. transmit "s"                   ; stop listing files
  207. waitfor "?=HELP) ->"           ; Wait for top command
  208. transmit "^^^"                 ; go to top menu
  209. waitfor "?=HELP) ->" 15
  210. endproc                        ; end of 'newfiles' procedure
  211.  
  212.  
  213. ;**********************************************
  214. proc accesser     ; do an 'access' on each file name in a list
  215. strparm filearea  ; file area to access
  216. string  filename = "c:\pcplus\asp\execaccs." ; name of list file
  217. string request = "~~f;?^M"     ; Files/area
  218.  
  219. strcat filename filearea       ; add file area to file name
  220. isfile filename                ; does the file exist?
  221. if not success
  222.    goto exit_access            ; no, skip this procedure
  223.    endif
  224.  
  225. strupdt request filearea 4 1   ; plug file area in place of ?
  226. transmit ";"
  227. waitfor "Chain->" 90
  228. transmit request               ; get new files the file list
  229. waitfor "?=HELP) ->"           ; Wait for top command
  230.  
  231. fopen 0 filename "rt"          ; open the file as read/text
  232.  
  233. access_read:
  234. fgets 0 s0                     ; read a record
  235. if eof 0                       ; was end-of-file encountered?
  236.    goto end_acc_file           ; yes, exit the procedure
  237.    endif
  238. substr s1 s0 0 12              ; pull out the filename (1st 12 bytes)
  239. strcat s1 "^M"                 ; append a CR
  240. transmit "A"                   ; (A) is for (A)ccess
  241. waitfor  " ->"
  242. transmit s1                    ; transmit the filename/CR
  243. when 2 "RETURN to quit) ->" transmit "^M"   ; if filename was not found
  244. waitquiet 15 forever           ; wait forever for 15 seconds of quiet
  245. cwhen 2                        ; clear when/2
  246. goto access_read
  247.  
  248. end_acc_file:
  249. fclose 0
  250. transmit "Q"                   ; quit the (A)ccess area
  251. waitfor "?=HELP) ->" 15        ; Wait for top command
  252. if waitfor
  253.    delete filename             ; delete the access-request file
  254.    endif
  255.  
  256. exit_access:
  257. transmit "^M"                  ; just in case we're stuck
  258. transmit "^^^"                 ; go to top menu
  259. waitfor "?=HELP) ->" 90
  260. return                         ; exit the procedure
  261. endproc                        ; end of 'accesser' procedure
  262.  
  263. ;**********************************************
  264. proc download                  ; download a list of files
  265. strparm filearea               ; file area to download
  266. string  filename = "c:\pcplus\asp\execfile."     ; name of the file
  267. string  downlog  = "c:\pcplus\asp\download.log"  ; name of d/l log file
  268. string  request = "~~f;?^M"    ; Files/area
  269.  
  270. strcat filename filearea       ; add file area to file name
  271. isfile filename                ; does the file exist?
  272. if not success
  273.    goto exitdlproc             ; no, exit the procedure
  274.    endif
  275.  
  276. strupdt request filearea 4 1   ; plug file area in place of ?
  277. transmit ";"
  278. waitfor "Chain->" 90
  279. transmit request               ; get new files the file list
  280. waitfor "?=HELP) ->"           ; Wait for top command
  281.  
  282. fopen 0 filename "rt"          ; open the file as read/text
  283. transmit "D"                   ; (D) is for (D)ownload
  284. waitfor  "from the BBS ->"
  285. if not waitfor                 ; if we got lost
  286.    goto exitdlproc
  287.    endif
  288.  
  289. dl_read:
  290. fgets 0 s0                     ; read a record
  291. if eof 0                       ; was end-of-file encountered?
  292.    goto end_dl_file            ; yes, quit this loop
  293.    endif
  294. substr s1 s0 0 12              ; pull out the filename
  295. strcat s1 "^M"                 ; append a CR
  296. transmit s1                    ; transmit the filename/CR
  297. waitfor  "from the BBS ->"
  298. goto dl_read
  299.  
  300. end_dl_file:
  301. fclose 0                       ; close the file
  302. transmit "^M"                  ; no more files to download
  303. waitfor "OK? (YNG) ->" 15
  304. if not waitfor                 ; if we screwed up
  305.    goto exitdlproc             ; let's get out of here
  306.    endif
  307. transmit "Y"                   ; Yes, do Zmodem transfer
  308. ; At this point, ProComm Plus detects the Zmodem signal and begins reception
  309. waitquiet 60 forever           ; Wait for silence (downloads are complete)
  310.  
  311. ; Now we're going to add the list of downloaded files to the download log.
  312. ; It's a handy way to remember what files you've downloaded.
  313.  
  314. fopen 0 filename "rt"          ; open the download file as read/text
  315. isfile downlog                 ; does the logfile already exist?
  316. if success
  317.         fopen 1 downlog "at"   ; yes, open in append mode
  318.    else
  319.         fopen 1 downlog "wt"   ; no, open in write mode
  320.    endif
  321.  
  322. add_to_log:
  323. fgets 0 s0                     ; read a record from EXECFILE.?
  324. if eof 0                       ; if end-of-file,
  325.    goto end_log_add            ;    get out
  326.    endif
  327. fputs 1 s0                     ; write the record to DOWNLOAD.LOG
  328. goto add_to_log
  329.  
  330. end_log_add:                   ; finished adding to download.log
  331. fclose 0                       ; close EXECFILE.?
  332. fclose 1                       ; close DOWNLOAD.LOG
  333. delete filename                ; delete EXECFILE.?
  334.  
  335. exitdlproc:
  336. transmit "^M"                  ; in case we're stuck
  337. transmit "^^^"                 ; go to top menu
  338. waitfor "?=HELP) ->" 90
  339. return                         ; exit the procedure
  340. endproc                        ; end of 'download' procedure
  341.  
  342. comment
  343. ****************************************************************************
  344.   If you find this script useful, please let me know.
  345.   If you make improvements to it, definitely let me know.  I have tried
  346.   to think of everything but that is, of course, impossible.
  347.   Even if you try this script and don't like it, I would appreciate
  348.   hearing about it.  All comments are welcome. 
  349.  
  350.   Bruce Clawson  -  Wauwatosa, WI  (USA)
  351. ****************************************************************************
  352. endcomment
  353.